plugins {
	id 'java'
	id 'org.springframework.boot' version '3.2.2'
	id 'io.spring.dependency-management' version '1.1.4'
	id 'org.siouan.frontend-jdk17' version '8.0.0'
	id 'jacoco'
}

ext {
	lombokVersion = '1.18.30'
	jacksonVersion = '2.15.3'
}

group = 'dev.gordeev'
version = '0.0.1'

java {
	sourceCompatibility = '17'
}

frontend {
	nodeVersion = '20.11.0'
	installScript = 'install'
	packageJsonDirectory= file("${projectDir}/src/ui")
	nodeInstallDirectory = file("${projectDir}/src/ui/node")
	assembleScript = 'run build'
}


tasks.register('copyReactApp', Copy) {
	from "${projectDir}/src/ui/build"
	into "${projectDir}/build/resources/main/public/."
}

bootJar.dependsOn(copyReactApp)
bootJar {
	mainClass = 'dev.gordeev.backend.BackendApplication'
}
jar {
	enabled = false
}

configurations {
	compileOnly {
		extendsFrom annotationProcessor
	}
}

repositories {
	mavenCentral()
	maven{
		url 'https://maven.atlassian.com/3rdparty/'
	}
}

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-webflux'
	implementation 'org.springframework.boot:spring-boot-starter-validation'
	implementation 'org.springdoc:springdoc-openapi-starter-webflux-ui:2.3.0'

	implementation 'com.github.oshi:oshi-core:6.4.10'
	implementation 'org.slf4j:slf4j-api:2.0.9'
	implementation 'org.projectlombok:lombok:1.18.30'
	implementation "com.fasterxml.jackson.core:jackson-core:$jacksonVersion"
	implementation "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
	implementation "com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion"

	developmentOnly 'org.springframework.boot:spring-boot-devtools'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'

	compileOnly "org.projectlombok:lombok:$lombokVersion"
	annotationProcessor "org.projectlombok:lombok:$lombokVersion"
	testCompileOnly "org.projectlombok:lombok:$lombokVersion"
	testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion"
}

tasks.named('test') {
	useJUnitPlatform()

	testLogging {
		events "passed"
	}
}

test {
	finalizedBy jacocoTestReport // report is always generated after tests run
}

jacocoTestReport {
	dependsOn test
	reports {
		xml.required = false
		html.required = false
		csv.required = true
	}
}
